package com.kotiln.lgc.aivoiceapp.adapter

import com.kotiln.lgc.aivoiceapp.R
import com.kotiln.lgc.aivoiceapp.data.ChatListData
import com.kotiln.lgc.aivoiceapp.entity.AppConstants
import com.kotiln.lgc.lib_base.adapter.CommonAdapter
import com.kotiln.lgc.lib_base.adapter.CommonViewHolder

/**
 *@fileName ChatListViewAdapter
 *@date2021/1/28  16:13
 *@author ChatListViewAdapter$
 *@describe TODO
 *@desc 对话列表适配器
 */
class ChatListViewAdapter(mList: List<ChatListData>) :
    CommonAdapter<ChatListData>(mList, object : OnMoreBindDataListener<ChatListData> {

        override fun onBindViewHolder(
            model: ChatListData,
            viewHolder: CommonViewHolder,
            type: Int,
            position: Int
        ) {
                when(type){
                    AppConstants.TYPE_MINE_TEXT -> viewHolder.setText(R.id.tv_mine_text,model.text)
                    AppConstants.TYPE_AI_TEXT -> viewHolder.setText(R.id.tv_ai_text,model.text)
                    AppConstants.TYPE_AI_WEATHER -> R.layout.layout_ai_weather
                    else -> 0
                }
        }

        override fun getLayoutId(type: Int): Int {
            return when (type) {
                AppConstants.TYPE_MINE_TEXT -> R.layout.layout_mine_text
                AppConstants.TYPE_AI_TEXT -> R.layout.layout_ai_text
                AppConstants.TYPE_AI_WEATHER -> R.layout.layout_ai_weather
                else -> 0
            }
        }

        override fun getItemType(position: Int): Int {
            return mList[position].type
        }

    }) {

}